<link rel="stylesheet" href="/static/css/cart.css" />
<div class="p-main">
		<div class="container">
			<div class="row">
				<div class="box pay-box">
					<div class="box-head clearfix webfont">
						<h2 class="pull-left">
                            支付订单
						</h2>
					</div>
					<div class="box-body">
						<div class="clearfix webfont">
                           <h2 class="pull-left">
	                         	<img style="vertical-align: middle; margin-right: 6px;" src="/static/images/dui.jpg">您的订单已提交成功，请立即付款，我们将为您马上开通课程！
							</h2>
                        </div>
						<div class="price-box"  style="margin-top: 20px; margin-left: 30px;">
							<div class="i-group" pay_type="all_pay">
								<span class="label">订单编号：<span class="red"><?php echo $order->order_sn ?></span></span>
							</div>
						</div>
						<div class="price-box"  style="margin-top: 20px; margin-left: 30px;">
							<div class="i-group" pay_type="first_pay">
								<span class="label">订单金额：<span class="red" id="price" price="<?php echo $order->price_amount ?>" >￥ <?php echo $order->price_amount ?> 元</span></span>
							</div>
						</div>
						<div class="price-box"  style="margin-top: 20px; margin-left: 30px;">
							<div class="i-group" pay_type="first_pay">
								<span class="label">订单名称：<span class="red">购买课程</span></span>
							</div>
						</div>

						<div class="pay-type">
							<span class="text">使用咖啡豆</span>
							<span class="pay-type-list">
							<form action="/index.php/course/order-pay" method="get">
								<input type="text" id="coin" name="coin" value=""> <span id="coin_amount" name="<?php echo $coin; ?>">(1咖啡豆=1元  剩余: <?php echo $coin; ?>咖啡豆);</span>
							</span><br>
							<span id="coin_erro"></span>
						</div>
						<div class="pay-type">
							<span class="text">选择支付方式</span>
							<span class="pay-type-list">
								<em class="item item-active" num="1"><img src="/static/images/pay-4.png"></em>
                               <!--  <em class="item" style="padding: 10px 16px;" num="4"><img style="vertical-align: middle; margin-right: 6px;" src="/static/images/weixi_icon.png">微信支付</em>
                                -->
							</span>
						</div>

						<div class="end-money-box">
							<div  class="text-right">支付金额：<em class="red"><span id="pay_amount"><?php echo $order->price_amount ?></span> 元</em></div>

								<input type="hidden" name="order_id" value="<?php echo $order->order_id?>">
								<div class="text-right btn-box">
									<input id="submit_order" type="submit" class="btn" value="&nbsp;&nbsp;&nbsp;&nbsp;支付&nbsp;&nbsp;&nbsp;&nbsp;" type="button">
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>


<script>
	$(function(){
		$("#coin").keyup(function() {
			var price = $("#price").attr('price')
			var ceil_price = Math.ceil(price);
			var coin_amount = $("#coin_amount").attr('name');
			var coin = $(this).val();
			if (coin =="") {
				coin =0;
			}
			if (parseInt(coin) != coin ) {
				$("#coin_erro").text("使用的咖啡豆必须是整数");
				$("#submit_order").attr('disabled', 'disabled');
				return false;
			}else{
				$("#coin_erro").text("");
				$("#submit_order").removeAttr('disabled')
			};
			if (coin > coin_amount) {
				$("#coin_erro").text("您的咖啡豆不足");
				$("#submit_order").attr('disabled', 'disabled');
				return false;
			}else{
				$("#coin_erro").text("");
				$("#submit_order").removeAttr('disabled', 'disabled');
			}
			if (coin > ceil_price) {
				$("#coin_erro").text("本次使用豆币最大为"+ceil_price+"个");
				$("#submit_order").attr('disabled', 'disabled');
				return false;
			}else{
				$("#coin_erro").text("");
				$("#submit_order").removeAttr('disabled', 'disabled');
			}

			var new_price = price-coin;
			if (new_price<0) {
				new_price = 0.00
			}
			$("#pay_amount").text(new_price.toFixed(2));
			return  true;
		});

	})

</script>